

import java.util.ArrayList;
import java.util.Random;

public class Test {
    public static void main(String[] args) {
        Algorithm listNode = new Algorithm();

        Random random = new Random(); // 随机初始化链表

        int k = 10;
        for (int i = 0; i < k; i++) {
            listNode.addLast(random.nextInt(200));
        }
        // 逆序前打印
        listNode.print(listNode.head);

        ArrayList<Integer> ret = Algorithm.printListFromTailToHead(listNode.head);
        // 逆序后打印
        System.out.println(ret);
    }
}
